﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EZCRS.HCMS.Data;
using System.Data.SqlClient;

namespace EZCRS.HCMS.SqlClient
{
    public class Sql_BookLogView
    {
        public System.Data.DataSet GetBookLog(string columnStr, string searchStr, string orderStr, int pageIndex)
        {
            return ExecSql.AddParamFrKeyField("hcrs_booklog", columnStr, orderStr, " id ", CFun.PageSize, pageIndex, searchStr);
        }

        public System.Data.DataRow GetBookLog(int id)
        {
            try
            {
                return ExecSql.GetDataSet("select * from hcrs_booklog where id=" + id.ToString()).Tables[0].Rows[0];
            }
            catch
            {
                return null;
            }
        }

        public bool UpdateStatus(string bookstatus, string bookgetstatus, int id)
        {
            SqlParameter[] pam = new SqlParameter[3];
            pam[0] = new SqlParameter("@status", bookstatus);
            pam[1] = new SqlParameter("@getstatus", bookgetstatus);
            pam[2] = new SqlParameter("@id", id);

            if (ExecSql.SqlExecNoquery("update hcrs_resvlog set status=@status where id=@id;update hcrs_resvlog_sub set getstatus=@getstatus where verifycode=(select verifycode from hcrs_resvlog where id=@id)", pam) > 0)
                return true;
            else
                return false;

        }
    }
}
